<script setup lang="ts">
import {ref,onBeforeMount} from "vue";
import { queryDictChild } from "@/api/dict";
import SaveOrUpdate from "./SaveOrUpdate.vue";
//绑定表格
const tableData=ref();

//是否展示
const isShow=ref(true);

//接收父组件传来的id
const props = defineProps({
  pid: {
    type: Number,
    request: true
  }
})

//根据穿过来的id进行查询
async function query() {
  let res = await queryDictChild(props.pid);
  if (res.code == 200){
    tableData.value = res.data;
  }
}

//声明周期函数
onBeforeMount(() => {
  query();
})
</script>

<template>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column type="index" label="id" width="180" />
    <el-table-column prop="code" label="编码" width="180" />
    <el-table-column prop="name" label="名称" />
    <el-table-column prop="sorts" label="排序" width="180" />
  </el-table>
  <SaveOrUpdate
  :visible="isShow"
  />
</template>

<style scoped lang="scss">

</style>
